package com.juli.school.app.controller.module;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.juli.school.dao.entity.Pub;
import com.juli.school.service.bo.MallBo;
import com.juli.school.service.bo.RecBo;
import com.juli.school.service.enums.EnumModule;
import com.juli.school.service.impl.MallService;
import com.juli.school.service.impl.RecService;
import com.juli.school.utils.core.model.CommonResp;
import com.juli.school.utils.core.model.ListResp;
import com.juli.school.utils.core.model.PageResp;

/**
 * @Description: 闪购控制器
 * @author: Eve
 * @date: 2017/9/8.
 */
@Controller
@RequestMapping("/mall")
public class MallController {
	
	@Resource
	MallService mallService;
	
	@Resource
	RecService recService;
	
	@RequestMapping("/listPage")
	@ResponseBody CommonResp<PageResp<Pub>> listPage(MallBo mallBo) {
		return mallService.listPage(mallBo);
	}
	
	/**
	 * @Description: 增量查询信息列表
	 * @author gaoxiang
	 * @date 2017年9月16日 下午10:27:17
	 */
	@RequestMapping("/list")
	@ResponseBody CommonResp<ListResp<Pub>> list(MallBo req) {
		return mallService.list(req);
	}
	
	@RequestMapping("/detail")
	@ResponseBody CommonResp<MallBo> detail(MallBo mallBo) {
		return mallService.detail(mallBo);
	}
	
	@RequestMapping("detailer")
	public String detailer(MallBo mallBo,ModelMap model){
		model.put("type", EnumModule.Mall);
		CommonResp<List<RecBo>> list = recService.list(mallBo.getSnStamp());
		model.put("recs", list.getData());
		model.put("obj",  mallService.detail(mallBo));
		return "/detail/index";
	}
}
